package com.deng.wxmessagecallback.config.apollo;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author wbdengtt
 * @date 2021/1/12 13:59
 * 暂时使用bizcom的apollo
 */
@Component
public class ApolloConfig {
    private static final String DEFAULT_VAL = "";

    private ApolloConfig() {
    }

    private static final String BASE_CONF_KEY = "application";
    private static final String EMPTY_STR = "";
    private static final Map<String, Config> CONFIG_MAP = new ConcurrentHashMap<>();

    static {
        CONFIG_MAP.put(BASE_CONF_KEY, ConfigService.getConfig(BASE_CONF_KEY));
    }

    /**
     * getBasicValue
     * 获取application上的值
     *
     * @param paramKey 对应apollo上面的key
     * @return 返回value
     */
    public static String getBaseValue(String paramKey) {
        return CONFIG_MAP.get(BASE_CONF_KEY).getProperty(paramKey, EMPTY_STR);
    }






}
